package board.dao;

import java.sql.SQLException;
import java.util.List;

import board.model.BoardVo;
import com.util.SqlMapLocator;

public class BoardDAO {
	private static BoardDAO singleton;
	private BoardDAO(){
	}
	public static BoardDAO getInstance(){
		if(singleton == null)
			singleton = new BoardDAO();
		return singleton;
	}
	
	public List<BoardVo> list(Object obj) throws SQLException{
		List<BoardVo> list = (List<BoardVo>)SqlMapLocator.getMapper().queryForList("BoardList",obj);
		return list;
	}
	
	public void insert(Object obj) throws SQLException{
		SqlMapLocator.getMapper().insert("BoardInsert", (BoardVo)obj );
	}
	
	public BoardVo selectBoard(Object obj) throws SQLException{
		BoardVo vo = (BoardVo)SqlMapLocator.getMapper().queryForObject("BoardOne",obj);
		return vo;
	}
	public int getMaxSeq() throws SQLException{
		return ((Integer)SqlMapLocator.getMapper().queryForObject("BoardMaxSeq")).intValue();
	}
	public void updateStep(Object obj) throws SQLException{
		SqlMapLocator.getMapper().update("BoardStepUpdate",obj);
	}
	public void updateHit(Object obj) throws SQLException{
		SqlMapLocator.getMapper().update("BoardHitUpdate",obj);
	}
	public void update(Object obj) throws SQLException{
		SqlMapLocator.getMapper().update("BoardUpdate",obj);
	}
	public void delete(Object obj) throws SQLException{
		SqlMapLocator.getMapper().update("BoardDelete",obj);
	}
	public int getRowCount(Object obj) throws SQLException{
		return ((Integer)SqlMapLocator.getMapper().queryForObject("BoardCnt",obj)).intValue();
	}
	
}
